﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UI.ParentForm;
using System.Collections;
using UI.Lib;

namespace UI.BaseResource
{
    public partial class FrmPsn2a00Edit : BaseEdit
    {
        public FrmPsn2a00Edit(string action, string text, string key)
            : base(action)
        {
            InitializeComponent();

            this.Text = text;
            this.key = key;
            //回写的方法
            this.SaveCallFuntion = "Psn2a00Manager$SaveData"; //保存的方法
            if ("A" == this.Action)
            {
                IsAfterSaveCloseWin = false;
            }
            else
            {
                LoadData();
            }

            this.Size = base.MidWindow;
        }

        protected override bool Check()
        {
            if ("A" == this.Action)
            {
                Hashtable hs = new Hashtable();
                hs["empno"] = this.tbSummary.GetValue("empno");
                hs["%usercode"] = Context.GetAppKeyWhere();
                bool reflt = UI.Lib.Factory.CommonHelper.Entity.DataInData("Psn2a00", hs);
                if (reflt)
                {
                    MessageBox.Show("当前人员工号已经存在！", "提示");
                    this.tbSummary.Focus("empno");
                    return false;
                }

                return true;
            }

            return true;
        }

        //加载修改数据
        private void LoadData()
        {
            base.LoadEditData(null, string.Format(" listid ='{0}' ", this.key));
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if ("depno" == name)
            {
                where = string.Format(" comcode = '{0}' ", Context.User.Comcode);
            }
            return true;
        }
    }
}
